package com.mobinters.cafeman;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.ImageButton;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.mobinters.cafeman.R;
import com.mobinters.web.AsyncWebView;

public class DetailActivity extends Activity implements OnClickListener{
		
		ProgressBar mProgressBar;
		ImageButton mBtnRefresh;
		String mUrl="";
		String mTitle="";
		AsyncWebView mWeb;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			requestWindowFeature(Window.FEATURE_NO_TITLE);
			setContentView(R.layout.meal_web);
			
			findViewById(R.id.action_bar_logo).setOnClickListener(this);
			mBtnRefresh=(ImageButton)findViewById(R.id.btn_refresh);
			mBtnRefresh.setOnClickListener(this);
			mProgressBar=(ProgressBar)findViewById(R.id.progressBar);
			mProgressBar.setVisibility(View.INVISIBLE);
			
			WebView wview=(WebView)findViewById(R.id.tutor_web);
			mWeb=new AsyncWebView(this, wview, mProgressBar);
			mWeb.settings(0);
			
			Intent i=getIntent();
			mUrl=i.getStringExtra("content");
			mTitle=i.getStringExtra("title");
			TextView tv=(TextView)findViewById(R.id.txt_web_title);
			tv.setText(mTitle);
			Log.e("URL",mUrl);
			//mWeb.loadAsync(mUrl);
			mWeb.loadUrl(mUrl);
		}

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			int id = v.getId();
			switch(id){
			case R.id.action_bar_logo:
				finish();
			break;
			
			case R.id.btn_refresh:
				//mWeb.loadAsync(mUrl);
				mWeb.loadUrl(mUrl);
			break;
			}
		}
}
